package website.digitalocean.chapter19;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author: longhc@citycloud.com.cn
 * @since: 2023/2/16 14:11
 * @version: 1.0
 */
public class Computer implements ComputerPart {

    private List<ComputerPart> partList;

    public Computer() {
        partList = Lists.newArrayList(new Mouse(), new Monitor(), new KeyBoard());
    }

    @Override
    public void accept(ComputerPartVisitor visitor) {
        for (ComputerPart computerPart : partList) {
            computerPart.accept(visitor);
        }
        visitor.visit(this);
    }
}
